home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 001-010 / amok07 / stack / testofstack.mod < prev    next >
Encoding:
Text File  |  1993-11-04  |  2.1 KB  |  66 lines

  1. (*********************************************************************
  2.  *                                                                   *
  3.  *  :Program.    TestOfStack.mod                                     *
  4.  *  :Author.     Michael Frieß                                       *
  5.  *  :Address.    Kernerstr. 22a                                      *
  6.  *  :shortcut.   [MiF]                                               *
  7.  *  :Version.    1.0                                                 *
  8.  *  :Date.       14.09.88                                            *
  9.  *  :Copyright.  PD                                                  *
  10.  *  :Language.   Modula-II                                           *
  11.  *  :Translator. M2Amiga                                             *
  12.  *  :Imports.    Stack     (at least V1.0 --> Amok#7)                *
  13.  *  :Contents.   Test of module Stack                                *
  14.  *                                                                   *
  15.  *********************************************************************)
  16.  
  17. MODULE TestOfStack;
  18.  
  19. FROM InOut    IMPORT WriteString, WriteLn;
  20. IMPORT Stack;
  21.  
  22. TYPE data = ARRAY [1..30] OF CHAR;
  23.  
  24. VAR s : Stack.stack;
  25.     Data : data;
  26.  
  27. BEGIN
  28.   WriteString ("Test of module stack:"); WriteLn;
  29.   WriteLn;
  30.  
  31.   WriteString ("* Initialize stack s"); WriteLn;
  32.   Stack.Init (s);
  33.  
  34.   WriteString ("* insert first element"); WriteLn;
  35.   Data := "First entry";
  36.   Stack.Write (s, Data);
  37.  
  38.   WriteString ("* insert second element"); WriteLn;
  39.   Data := "Second entry";
  40.   Stack.Write (s, Data);
  41.  
  42.   WriteString ("* insert third element"); WriteLn;
  43.   Data := "Third entry";
  44.   Stack.Write (s, Data);
  45.  
  46.   WriteString ("* read last element"); WriteLn;
  47.   Stack.Read (s, Data);
  48.   WriteString (Data); WriteLn;
  49.  
  50.   WriteString ("* insert fourth element"); WriteLn;
  51.   Data := "Fourth entry";
  52.   Stack.Write (s, Data);
  53.  
  54.   WriteString ("* read all elements until end of stack"); WriteLn;
  55.   WHILE NOT Stack.Empty(s) DO
  56.    Stack.Read (s, Data);
  57.    WriteString (Data); WriteLn
  58.   END;
  59.  
  60.   WriteString ("* discard stack"); WriteLn;
  61.   Stack.Discard (s);
  62.  
  63.   WriteString ("* End of Test"); WriteLn;
  64.  
  65. END TestOfStack.
  66.